package com.pingliuceng.stepup.utils;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import com.pingliuceng.stepup.modules.NeedParams;
import com.tencent.cloud.huiyansdkface.facelight.api.WbCloudFaceContant;
import com.tencent.cloud.huiyansdkface.facelight.api.WbCloudFaceVerifySdk;
import com.tencent.cloud.huiyansdkface.facelight.api.listeners.WbCloudFaceVerifyLoginListener;
import com.tencent.cloud.huiyansdkface.facelight.api.listeners.WbCloudFaceVerifyResultListener;
import com.tencent.cloud.huiyansdkface.facelight.api.result.WbFaceError;
import com.tencent.cloud.huiyansdkface.facelight.api.result.WbFaceVerifyResult;
import com.tencent.cloud.huiyansdkface.facelight.process.FaceVerifyStatus;

//import static com.alan.music.utils.ToastUtilKt.toast;

public class VerifyUtil {

    //拉起刷脸sdk
    public static void openCloudFaceService(Context context, NeedParams needParams) {
        Log.d("测试", "openCloudFaceService");
        Bundle data = new Bundle();
        WbCloudFaceVerifySdk.InputData inputData = new WbCloudFaceVerifySdk.InputData(
                needParams.getFaceId(),
                needParams.getOrderNo(),
                needParams.getAppId(),
                "1.0.0",
                needParams.getNonce(),
                needParams.getUserId(),
                needParams.getSign(),
                FaceVerifyStatus.Mode.GRADE,
                "Q5sBOcmVygfQJjdMcItosSpbz9ivBiY4RiMPpoogd9xpOjUQk9uqkxE/w9h8yTPR8pklsNZjOXT3ikedc9UEDNHKmP2qFVc8oFQotqOu5fCTC3iFTodmJ5TQ6Mh6hjqgD+rIXBQcztoQb8EpEQc0msh9oCpFVsMp1EcU+j4OcJwR0yFkqvU+aLnXQ7mhhWX2779bTejo59+V2SeM6xrE27gdrC7J4BCgu21vCIsiX/4VmMSJp0QkQzPDHK6EeMaLsZ2Hjn5u6r05YoTR/ROh8ie5E0B0vv3Qk9Sc0J8vgnkzdEW+HUtfR/1+twbHUcwWtoPZ+cM/h5ht3xC8bD4d5Q=="
        );
        data.putSerializable(WbCloudFaceContant.INPUT_DATA, inputData);
        //【特别注意】请使用activity context拉起sdk
        //【特别注意】请在主线程拉起sdk！
        WbCloudFaceVerifySdk.getInstance().initSdk(context, data, new WbCloudFaceVerifyLoginListener() {
            @Override
            public void onLoginSuccess() {
                //登录sdk成功
//                toast("登录成功");
                //拉起刷脸页面
                //【特别注意】请使用activity context拉起sdk
                //【特别注意】请在主线程拉起sdk！
                WbCloudFaceVerifySdk.getInstance().startWbFaceVerifySdk(context, new WbCloudFaceVerifyResultListener() {
                    @Override
                    public void onFinish(WbFaceVerifyResult result) {
                        //刷脸结束后，释放资源
                        WbCloudFaceVerifySdk.getInstance().release();
                    }
                });
            }

            @Override
            public void onLoginFailed(WbFaceError error) {
//                toast("登录失败");

                //刷脸结束后，释放资源
                WbCloudFaceVerifySdk.getInstance().release();
            }
        });
    }
}
